﻿using huaxin_core.Page;
using huaxin_Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace huaxin_DAO
{
    public class huaxin_PrizeDao
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public  PageDataView<huaxin_prize_extend> GetPrizePage(int id, int page, int pageSize = 10)
        {

            PageCriteria criteria = new PageCriteria();
            criteria.Condition = "1=1";

            criteria.CurrentPage = page;
            criteria.Fields = "*";
            criteria.PageSize = pageSize;
            criteria.TableName = " huaxin_prize p join huaxin_users u on p.OpenId=u.OpenId ";
            criteria.PrimaryKey = "Id";

            StringBuilder fields = new StringBuilder();
            fields.Append(" p.OpenId,p.PrizeId,p.PublishDate,");
            fields.Append(" u.NickName,u.Phone");

            var result = SqlConn.GetPageData<huaxin_prize_extend>(criteria);

            return result;
        }


    }
}
